﻿<style>
	#loadfile{
		position: absolute;
		z-index: 1;
		opacity: 0;
		-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
		filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
		top: 0;
	}
	.layui-input-loadfile{
		position: relative;
	}
	.layui-inline{
		height: 40px;
	}
</style>
<span class="layui-breadcrumb">
    <a href="javascript:void(0)">当前位置:</a>
    <a href="javascript:void(0)">银行端系统菜单 > </a>
    <a href="javascript:void(0)"><cite>银行人员管理</cite> </a>
</span>
<div class="layui-form-item layui-form-item-top">
	<@shiro.hasPermission name="empadd">
	<button class="layui-btn-tan" id="addUser">
		<i class="layui-icon">&#xe608;</i> 添加
	</button>
	</@shiro.hasPermission>
</div>

<div style="height: 35px;">
	<div class=" layui-inline" id="searchbox">
		<@shiro.hasPermission name="search">
		<div class="layui-input-inline">
			<input type="text" name="searchConent" value="${pd.keywords}" lay-verify="title" autocomplete="off" placeholder="请输入关键字" class="layui-input">
		</div>
		<div class="layui-input-inline">
			<input type="button" value="查询" onclick="searchs();" class="layui-btn layui-btn-red"/>
		</div>
	</@shiro.hasPermission>
</div>
<@shiro.hasPermission name="upload">
<div class="layui-inline" style="  float: right; margin-right: 15px;">
	<div class="layui-input-inline layui-input-loadfile">
		<input style="width: 200px;text-indent: 6px" type="text" value="" id="uploadInput" placeholder="请选择上传文件"/>
		<input id="loadfile" onchange="uploadInput()" style="width:187px" type="file" name="loadfile">
	</div>
	<div class="layui-input-inline">
		<input  type="button" value="上传" style="margin-right: 20px" onclick="uploadImport();" class="layui-btn layui-btn-red"/>
	</div>
	<@shiro.hasPermission name="empdaochu">
		<input type="button"  value="导出员工信息模版" onclick="exportExcel()"  class="layui-btn layui-btn-red">
	</@shiro.hasPermission>
</div>
</@shiro.hasPermission>
</div>
<form class="layui-form" action="${basePath}bank/operator" type="0" method="post" name="operatorForm" id="operatorForm">
    <!--<div class="searchbox" id="searchbox">-->
        <!--<input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">-->
        <!--<input type="button" value="查询" onclick="searchs();" class="layui-btn layui-btn-red"/>-->
    <!--</div>-->
	<div class="levTable">
		<table id="simple-table" class="table table-striped table-bordered table-hover" >
				<thead>
				<tr>
					<th style="width: 60px"><input lay-skin="primary" type="checkbox" lay-filter="checkbox" name="no">全选</th>
					<th style="width:90px;">员工编号</th>
					<th style="width: 100px">员工姓名</th>
					<th style="width: 100px">机构代码</th>
					<th style="width: 150px">手机号码</th>
					<th style="width: 40px">邮箱</th>
					<th style="width: 150px">状态</th>
					<th style="width: 80px">角色</th>
					<th style="width: 180px;">操作</th>
				</tr>
				</thead>
				<tbody>
				<#list operatorList?if_exists as operator>
					<tr>
						<td><input lay-skin="primary" type="checkbox" lay-filter="choose" name="ids" value="${operator.operatorId}"></td>
						<td>${operator.operatorId}</td>
						<td>${operator.operatorName}</td>
						<td>${operator.orgId}</td>
						<td>${operator.phone}</td>
						<td>${operator.email}</td>
						<td>${operator.status}</td>
						<td>${operator.roleName}</td>
						<td >
							<a class="layui-icon" onclick="getUser('${operator.operatorId}');" title="查看">&#xe63c;</a>
							<a class="layui-icon" onclick="editUser('${operator.operatorId}');" title="修改">&#xe642;</a>
<!--							<@shiro.hasPermission  name="empLook">
							<a class="layui-icon" onclick="getUser('${operator.comUserCode}');" title="查看">&#xe63c;</a>
							</@shiro.hasPermission>
							<@shiro.hasPermission  name="empupdate">
							<a class="layui-icon" onclick="editUser('${operator.comUserCode}');" title="修改">&#xe642;</a>
							</@shiro.hasPermission>
							<@shiro.hasPermission  name="empdel">
							<a class="layui-icon" onclick="deleteUser('${operator.comUserCode}');" title="删除">&#xe640;</a>
							</@shiro.hasPermission>
							<@shiro.hasPermission  name="limit">
							<a class="layui-icon" onclick="limitUser('${operator.comUserCode}','${operator.comCode}');" title="角色授权">&#xe612;</a>
							</@shiro.hasPermission>
							<@shiro.hasPermission name="updatepassword">
							<a class="layui-icon" onclick="resetPassWord('${operator.comUserCode}','${emp.comUserName}');" title="重置密码">&#xe614;</a>
							</@shiro.hasPermission>-->
						</td>
					</tr>
				</#list>
				</tbody>
			</table>
	</div>
	<#include "/common/page.html" />
<@shiro.hasPermission name="piliangshanchu">
	<div class="layui-form-item" style="text-align: right;float: right;clear: none;">
		<input type="button" value="批量删除" onclick="delSalTempData()" class="layui-btn layui-btn-red"/>
	</div>
</@shiro.hasPermission>
</form>
<script type="text/javascript" src="${basePath}static\js\ajaxfileupload.js"></script>
<script type="text/javascript">

    var form;
    layui.use('form', function () {
        form = layui.form();

        form.on('checkbox(checkbox)', function(data){

            debugger;
            if(data.elem.checked){
                $("input[name*=\'ids\']").prop("checked",true);
            }else{
                $("input[name*=\'ids\']").prop("checked",false);
            }
            form.render();
        });
        form.render();
    });
	var rooturl = "${basePath}bank/operator";
	//检 索
	function searchs() {
		_GLOBE_DATA("reLoadPageParam")(_GLOBE_DATA("createURL")(rooturl,"searchbox"));
	}
	function uploadInput() {
		$("#uploadInput").val($("#loadfile").val());
    }
	function getUser(id){
		reLoadPage("sysuser/user/getUserById?comUserCode="+id);
	}
	//批量删除
    function delSalTempData(){
        var no = '';
        $('input[name*=ids]:checked').each(function(){
            no += ","+$(this).val();
        });
        if(no == ''){
            layer.alert("请至少选择一行数据！");
            return;
        }
        layer.confirm('确认要删除吗？', {
            btn: ['确定', '取消']
        }, function(index, layero){
            var url = "${basePath}sysuser/user/deleteTempData?ids="+no;
            $.ajax({url: url,
                type: "POST",
                success: function(data){
                    if (data.status == 'success') {
                        layer.alert(data.msg,function(index){
                            var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index1);
                            parent.layer.close(index);
                            reLoadPage(rooturl);
                        });
                    } else {
                        layer.alert(data.msg);
                    }
                }
            })
        });
    }
	//重置密码
	function resetPassWord(comUserCode,comUserName){
        $.ajax({
            url : '${basePath}sysuser/user/resetPassWord',
            data : {
				comUserCode : comUserCode,comUserName : comUserName
            },
            type : "POST",
            success : function(data) {
                if (data.status == 'success') {
                    layer.alert(data.msg,function(index){
						var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
						parent.layer.close(index1);
						parent.layer.close(index);
						reLoadPage(rooturl);
                    });
                } else {
                    layer.alert(data.msg);
                }
            }
        });
	};

    
	//修改
	function editUser(comUserCode) {
		var _url = $("form:eq(0)").attr("action");

		layer.open({
			type : 2,//此处以iframe举例
			title : '用户信息编辑',
			area : [ '480px', '600px' ],//刘佳 2017-9-15 14:57
			content : '${basePath}sysuser/user/toUserEdit?comUserCode='+comUserCode,
			btn : [ '保存', '关闭' ], //只是为了演示
			yes : function(index, layero) {
				var iframeWin = window[layero.find('iframe')[0]['name']];
				iframeWin.update();
			},
			no : function(index) {
			//	layer.close(index);
			},
			end : function() {
				reLoadPage(rooturl);
			}
		});
	}

	//删除
	function deleteUser(comUserCode) {
		layer.confirm('确认要删除吗？', {
			btn: ['确定', '取消']
		}, function(index, layero){
			$.ajax({
				url : '${basePath}sysuser/user/deleteSysUser',
				data : {
					comUserCodes : comUserCode
				},
				type : "POST",
				success : function(data) {
					if (data.status == 'success') {
						layer.alert(data.msg,function(index){
							var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
							parent.layer.close(index1);
							parent.layer.close(index);
							reLoadPage(rooturl);
						});
					} else {
						layer.alert(data.msg);
					}
				}
			});
		});
	}
	
	//用户授权
	function limitUser(userId,comCode) {

		var url = encodeURI(encodeURI('${basePath}sysuser/user/toUserLimit?empId='+userId+"&comCode="+comCode))
		layer.open({
			type : 2,//此处以iframe举例
			title : '用户权限设置',
			area : [ '550px', '450px' ],
			content : url,
			btn : [ '保存', '关闭' ], //只是为了演示
			yes : function(index, layero) {
				var iframeWin = window[layero.find('iframe')[0]['name']];
				iframeWin.save();
			},
			no : function(index) {
				layer.close(index);
			},
			end : function() {
				reLoadPage(rooturl);

			}
		});
	}
	//添加
	$("#addUser").click(function(){
		var _url = $("form:eq(0)").attr("action");
		layer.open({
			type: 2,
			title : '添加员工',
			content: "${basePath}sysuser/user/toUserEdit",
			area: [ '480px', '600px'],//刘佳 2017-9-15 14:57
			btn: ['确定', '取消'],
			yes : function(index, layero) {
				var iframeWin = window[layero.find('iframe')[0]['name']];
				iframeWin.save();
			},
			no : function(index) {
				layer.close(index);
			},
			end : function() {
//                setTimeout("self.location.reload()", 100);
				reLoadPage(rooturl);
			}
		});
	});

	//上传文件
	function uploadImport(){
        if($.trim($("#uploadInput").val())== ""){
            layer.alert("请选择文件！");
            return;
        }
		$.ajaxFileUpload(
				{
					url:'${basePath}sysuser/user/readExcel',            //需要链接到服务器地址
					secureuri:false,
					fileElementId:'loadfile',                     //文件选择框的id属性
					// dataType: 'json',                          //服务器返回的格式，可以是json
					success: function (data, status){              //相当于java中try语句块的用法
						if(data.status == 'success'){
							layer.alert("上传成功");
							reLoadPage(rooturl);
						}else{
							layer.alert(data.msg);
						}
					},
					error: function (data, status, e)            //相当于java中catch语句块的用法
					{
						//$("#complate").show().text("上传失败！").css("color","#cc0033");
					}
				}
		);
	}
	function exportExcel()
	{
		window.location.href="${basePath}sysuser/user/getExPort";
	}

</script>
